package student.aistar.day15.thread01;

/**
 * 线程创建的第二种方式
 */
public class Thread02 implements Runnable{

    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName());
    }
}
class TestThread02{
    public static void main(String[] args) {
        //创建Runnable接口的实现类对象
        Runnable r = new Thread02();

        //创建两个线程
        Thread t1 = new Thread(r);
        Thread t2 = new Thread(r);

        t1.setName("线程one");
        t2.setName("线程two");

        //启动两个线程
        t1.start();
        t2.start();
    }
}
